assume cs:codesg,ds:data,ss:stack
data segment
	db 'Welcome to masm!',0
data ends

stack segment
	dd 16 dup(0)
stack ends

codesg segment
start:	mov ax,data
	mov ds,ax
	mov ax,stack
	mov ss,ax
	mov sp,10h
	mov bp,0
	mov si,0

	mov ax,9002h
	mov dx,7
	mov cx,3
	call divdw
	
	mov ax,4c00h
	int 21h

	;divide word with no divide overflow
	;dx: the high position of divisor
	;ax: the low position of divisior
	;cx: the num to be divided
	;ret dx:the high position of result
	;ret ax:the low position of result
	;ret cx:the remainder
divdw:
	push bp
	sub sp,4
	mov bp,sp
	
	mov [bp],ax
	mov ax,dx
	mov dx,0
	div cx
	mov [bp].2,ax
	mov ax,[bp]
	div cx
	mov cx,dx
	mov dx,[bp].2
	add sp,4
	pop bp
	ret

codesg ends
end start